﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace Tos2Google
{
	[Serializable]
	internal class old_Serializable
	{
		public void Save(string fileName)
		{
			BinaryFormatter formatter = new BinaryFormatter();
			using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
			{
				try
				{
					formatter.Serialize(fs, this);
				}
				finally
				{
					fs.Close();
				}
			}
		}

		public static old_Serializable Load(string fileName)
		{
			BinaryFormatter formatter = new BinaryFormatter();
			using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
			{
				try
				{
					return (old_Serializable)formatter.Deserialize(fs);
				}
				finally
				{
					fs.Close();
				}
			}
		}
	}

	[Serializable]
	internal class SerializableLogin : old_Serializable
	{
		public readonly string Server;
		public readonly string Database;
		public readonly bool IntegratedSecurity;
		public readonly string Username;
		public readonly string Password;

		public SerializableLogin(
			string server,
			string database,
			bool integratedSecurity,
			string username,
			string password)
		{
			Server = server;
			Database = database;
			IntegratedSecurity = integratedSecurity;
			Username = username;
			Password = password;
		}
	}

    [Serializable]
    internal class SerializableTDLogin : old_Serializable
    {
        public readonly string SourceID;
        public readonly string ApiVer;
        public readonly string Username;
        public readonly string Password;

        public SerializableTDLogin(
            string sourceID,
            string apiVer,
            string username,
            string password)
        {
            SourceID = sourceID;
            ApiVer = apiVer;
            Username = username;
            Password = password;
        }
    }

    [Serializable]
    internal class SerializableWCFLogin : old_Serializable
    {
        public readonly string Server;
        public readonly string Username;
        public readonly string Password;

        public SerializableWCFLogin(
            string Server,
            string username,
            string password)
        {
            Server = Server;
            Username = username;
            Password = password;
        }
    }
}
